/**   
 * @Title: BeidanExpectListCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.lotteryinfo 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author: Billy Qigs@500wan.com   
 * @date: 2012-1-10 下午7:07:24  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.lotteryinfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.ExpectListInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.log.EDebug;

/**
 * @ClassName: BeidanExpectListCommunicater
 * @Description: (北京单场期号列表获取接口)
 * @author: Billy Qigs@500wan.com
 * @date: 2012-1-10 下午7:07:24
 * 
 */
public class ExpectListCommunicater extends ServerCommunicater {

	public boolean isGetExpectListSucceed(String lotid, String playID, String type) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		boolean isSucceed = false;
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(Config.PASER_MID, BussinessCode.MID_EXPECT_LIST));
		list.add(mapItem(Config.PASER_CK, Config.NULLMARK));
		list.add(mapItem(Key.KEY_LOTID, lotid));
		list.add(mapItem(Key.KEY_PLAYID, playID));
		list.add(mapItem(Key.KEY_TYPE, type));

		super.getServerResponse(list, true);
		if (super.getState() == 100) {
			isSucceed = true;
			if (super.getListResult().size() == 0) {
				EDebug.o("list 为空");
				isSucceed = false;
			} else {
				EDebug.o("list 不为空");
			}
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public void updateExpecList() {

		ExpectListInfo.getExpectListInfo().cleanup();

		for (int i = 0; i < super.getListResult().size(); i++) {
			ExpectListInfo.getExpectListInfo().addExpect(super.getListResult().get(i).get(Key.KEY_EXPECT));
		}

	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
